﻿Namespace myBookmarks.Web
    ''' <summary>
    ''' Render view to string  
    ''' Adapted from: http://haacked.com/archive/2007/12/21/asp.net-mvc-helpers-for-repopulating-a-form.aspx
    ''' </summary>
    Public Module TempDataExtensions
        <System.Runtime.CompilerServices.Extension()> _
            Public Function FlashMessage(ByVal tempData As TempDataDictionary, ByVal key As String) As String
            Dim value As Object
            If Not tempData.TryGetValue(key, value) Then
                Return String.Empty
            End If
            Return "<div class=""message"">" & value.ToString() & "</div>"
        End Function
        <System.Runtime.CompilerServices.Extension()> _
          Public Function SafeGet(ByVal tempData As TempDataDictionary, ByVal key As String) As String
            Dim value As Object
            If Not tempData.TryGetValue(key, value) Then
                Return String.Empty
            End If
            Return value.ToString()
        End Function

    End Module

End Namespace